#include <command.h>
#include <stdio.h>
#include <string.h>

extern struct cmd __mboot_cmd_start;
extern struct cmd __mboot_cmd_end;

int cmd_usage(const struct cmd *cmd)
{
	puts(cmd->name);
	puts(" - ");
	puts(cmd->help);
	puts("\r\n\r\n");
	puts("Usage:\r\n");
	puts(cmd->name);
	puts(" ");
	puts(cmd->usage);
	puts("\r\n");
	
	return 0;
}

struct cmd *cmd_search(const char *cmd)
{
	struct cmd *cmdp;
	struct cmd *table = &__mboot_cmd_start;
	int table_len = &__mboot_cmd_end - &__mboot_cmd_start;

	if (!cmd) 
		return NULL;

	for (cmdp = table; cmdp != table + table_len; cmdp++) {
		if (strcmp(cmd, cmdp->name) == 0) {
			return cmdp;
		}
	}

	return NULL;
}


